package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    @Insert("insert into dish (name,category_id,price,image,description,status,create_time,update_time,create_user,update_user)" +
            "values (#{name},#{categoryId},#{price},#{image},#{description}," +
            "#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void saveDish(Dish dish);

    Page<Dish> page(DishPageQueryDTO dishPageQueryDTO);

//    void delete(List<Long> ids);
    /**
     * 删除菜品表中的菜品数据
     * @param id
     */
    void deleteById(Long id);

    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> list(Dish dish);

    List<Dish> getBySetmealId(Long id);

    Integer countByMap(Map map);
}
